package com.xiaozhu.utils;

/**
 * 线程上下文工具类
 * 用于存储当前线程的用户信息（ID、用户名）
 */
public class BeanContext {

    private static final ThreadLocal<Integer> THREAD_LOCAL_ID = new ThreadLocal<>();
    private static final ThreadLocal<String> THREAD_LOCAL_NAME = new ThreadLocal<>();

    public static void setId(Integer value) {
        THREAD_LOCAL_ID.set(value);
    }

    public static void setName(String value) {
        THREAD_LOCAL_NAME.set(value);
    }

    public static Integer getId() {
        return THREAD_LOCAL_ID.get();
    }

    public static String getName() {
        return THREAD_LOCAL_NAME.get();
    }

    public static void remove() {
        THREAD_LOCAL_ID.remove();
        THREAD_LOCAL_NAME.remove();
    }
}
